<?php
/**
 * Created on 28.09.2007 by Nikolai Plath
 *
 * @package B-Index
 * @file bindex.class.php
 */

class bindex extends mosDBTable
{
	var $id			= 0;
	var $id_item		= 0;
	
	var $id_stadt		= 0;//from other table..
	var $gmap_lat		= 0;//from other table..
	var $gmap_lng		= 0;//from other table..
	
	var $language		= 0;
	var $name			= NULL;
	
	var $strasse		= NULL;
	var $hausnummer	= NULL;
	var $telefon		= NULL;
	var $fax			= NULL;
	var $email			= NULL;
	var $bild			= NULL;
	var $beschreibung	= NULL;
    
    function bindex( &$db )
    { $this->mosDBTable( '#__bindex_items_data', 'id', $db );
    }//function
    
	
	function get ( $id, $language )
	{
		global $database;
		$item = NULL;
		
		$query = "SELECT * FROM `#__bindex_items_data`" .
				"\n WHERE `id_item` = '".$id."'" .
				"\n AND `language` = '".$language."'";
		$database->setQuery($query);
		$database->loadObject($item);
		
		return ($item);
	} //function
	
	function getFromRequest( $lang )
	{
		global $database;
		global $biConfig;

		if( $lang )
		{
			$this->id 				= intval( mosGetParam( $_REQUEST, 'bid_'.$lang, '') );
			$this->name 			= mosGetParam( $_REQUEST, 'name_'.$lang, '');

			$this->id_stadt			= intval( mosGetParam( $_REQUEST, 'id_stadt' ) );
			$this->gmap_lat			= floatval( mosGetParam( $_REQUEST, 'gmap_lat' ) );
			$this->gmap_lng			= floatval( mosGetParam( $_REQUEST, 'gmap_lng' ) );

			$this->strasse			= mosGetParam( $_REQUEST, 'strasse_'.$lang, '' );
			$this->hausnummer		= mosGetParam( $_REQUEST, 'hausnummer_'.$lang, '' );
			$this->telefon			= mosGetParam( $_REQUEST, 'telefon_'.$lang, '' );
			$this->fax				= mosGetParam( $_REQUEST, 'fax_'.$lang, '' );
			$this->email			= mosGetParam( $_REQUEST, 'email_'.$lang, '' );
			$this->beschreibung		= mosGetParam( $_REQUEST, 'beschreibung_'.$lang, '', _MOS_ALLOWHTML );
			$this->language			= $lang;
		} //if
	} //function
   
    function biStore ()
	{
		global $database;
		global $biConfig;
global $DBG;
//echo $this->name.'/'.$this->id.'/'.$this->id_stadt.'/'.$this->bild;
			
		if( $this->id == 0 )
		{//neu speichern
			if( trim($this->name) == '' )
			{ 	echo "NONAME..";
				return FALSE;
			} else
			{
				$query = "INSERT INTO `#__bindex_items`" .
						"\n ( `id_stadt`, `gmap_lat`, `gmap_lng`, `published` )" .
						"\n VALUES" .
						"\n ( '".$this->id_stadt."', " .
						"\n '".$this->gmap_lat."', " .
						"\n '".$this->gmap_lng."', " .
						"\n '1' )";
				$database->setQuery($query);
				$database->query($query);
$DBG->query($query);
				if( $database->getErrorNum() ) return FALSE;
				$this->id_item = mysql_insert_id();
	    		$this->biGetImage( $_FILES["bindexImg"] );
				$query = "INSERT INTO `#__bindex_items_data`" .
						"\n ( `id_item`, `language`, `name`, `strasse`, `hausnummer`, `telefon`, `fax`, `email`, `bild`, `beschreibung` )" .
						"\n VALUES" .
						"\n ( '$this->id_item' , '$biConfig->ini_language', '$this->name', '$this->strasse', '$this->hausnummer', '$this->telefon', '$this->fax', '$this->email', '$this->bild', '$this->beschreibung' )";
				$database->setQuery($query);	
				$database->query($query);
$DBG->query($query);

				return( $database->getErrorNum() ) ? FALSE : TRUE;
			}//if
		} else #aendern
		{

			$query = "UPDATE `#__bindex_items`" .
					"\n SET" .
					"\n `id_stadt` = '{$this->id_stadt}'," .
					"\n `gmap_lat` = '{$this->gmap_lat}'," .
					"\n `gmap_lng` = '{$this->gmap_lng}'," .
					"\n `published` = '1'" .
					"\n WHERE `id` = '{$this->id}'";
			$database->setQuery($query);
			$database->query($query);
				if( $database->getErrorNum() ) return FALSE;
$DBG->query($query);


			$query = "SELECT count(*) FROM `#__bindex_items_data`" .
					"\n WHERE `id_item` = '$this->id'" .
					"\n AND `language` = '$this->language'";
			$database->setQuery($query);
			$res = $database->loadResult();
$DBG->query($query);
			if( $database->getErrorNum() ) return FALSE;
			if( $res )
			{#Datensatz vorhanden
				if( trim($this->name) == '' )
				{ 	echo "NONAME..";
					return FALSE;
				} else
				{
		    		if(isset($_FILES["bindexImg"]) && is_array($_FILES["bindexImg"])) $this->biGetImage( $_FILES["bindexImg"] );
		    		$set_bild = '';
		    		if( $this->bild != '')
		    		{
		    		switch( $this->bild )
		    		{
		    			case 'kill':
//		    			die('killproc');
		    				$set_bild = "\n `bild` = '', ";
		    			break;
		    			default:
		    				$set_bild = "\n `bild` = '$this->bild', ";
		    			break;
		    		} //switch
		    		} //if
					$query = "UPDATE `#__bindex_items_data`" .
							"\n SET" .
							"\n `name` = '$this->name', " .
							"\n `strasse` = '$this->strasse', " .
							"\n `hausnummer` = '$this->hausnummer', " .
							"\n `telefon` = '$this->telefon', " .
							"\n `fax` = '$this->fax', " .
							"\n `email` = '$this->email', " .
							 $set_bild.
							"\n `beschreibung` = '$this->beschreibung'".
							"\n WHERE `id_item` = '$this->id'" .
							"\n AND `language` = '$this->language'";
					$database->setQuery($query);
					$database->query();
$DBG->query($query);
					return( $database->getErrorNum() ) ? FALSE : TRUE;
				}//if
			} else
			{#NEU
				if( trim($this->name) == '' )
				{ 	echo "NONAME..";
					return FALSE;
				} else
				{
		    		$this->biGetImage( $_FILES["bindexImg"] );
					$query = "INSERT INTO `#__bindex_items_data`" .
						"\n ( `id_item`, `language`, `name`, `strasse`, `hausnummer`, `telefon`, `fax`, `email`, `bild`, `beschreibung` )" .
						"\n VALUES" .
						"\n ( '$this->id ' , '$this->language', '$this->name', '$this->strasse', '$this->hausnummer', '$this->telefon', '$this->fax', '$this->email', '$this->bild', '$this->beschreibung' )";
					$database->setQuery($query);
					$database->query();
$DBG->query($query);
					return( $database->getErrorNum() ) ? FALSE : TRUE;
				}//if
			} //if
		} //if
	} //function

	function drawEmail()
	{
		$mail 			= mosHTML::encoding_converter( $this->email );
		$mail			= explode( '@', $mail );
		
		if(isset($mail[0]) && isset($mail[1]) ) 
		{
		 echo mosHTML::emailCloaking( $this->email );
		}
	} //function

	function biGetImage( $file ) {
		//global $mosConfig_absolute_path;
		global $biConfig;

		$biConfig->ChmodRecursive($biConfig->absolutePath.$biConfig->imagesFolder,0775);
		$fileExt = substr( $file['name'], -3 );
		/*
		 * check extension
		 */
		$allowedFile = 0;
		//$msg = "";

		/*
		 * check if file is not to big
		 */
		if($file['size'] > ($biConfig->maxFileSize * 1024)) {
			$Size = $file["size"]/1024;
			$Size = (int) $Size + 1;
			return _SOBI2_SAVE_IMG_TO_BIG.$Size._SOBI2_EF_KB_FILE_SIZE._SOBI2_EF_MAX_FILE_SIZE.$biConfig->maxFileSize._SOBI2_EF_KB_FILE_SIZE.". ";
		}
		/*
		 * check if file hat allowed extension
		 */
		foreach( $biConfig->allowableFilesExt as $allowableExt )
			if (strcasecmp( $fileExt, $allowableExt ) == 0)
				$allowedFile = 1;
    	/*
    	 * case file has allowed extension
    	 */
    	if($allowedFile) {
			$filename = $this->id_item.'_'.strtolower( $file['name']);
			if(@move_uploaded_file($file['tmp_name'], $biConfig->absolutePath.$biConfig->imagesFolder.$filename)){
					$this->bild = $filename;
					echo "BBB:".$this->bild;
					$this->resampleImage( $filename, 'img' );
					$this->resampleImage( $filename, 'tmb' );
					return TRUE;
					//$msg = $msg._BI_SAVE_UPLOAD_IMG_OK."<br/>";
			}
			else {
				//$msg = $msg._SOBI2_SAVE_UPLOAD_IMG_FAILED."<br/>";
			}
    	}
	    /*
		 * case this file has not allowed extension
		 */
		//else if($fileExt)
			//$msg =  $msg.'_BI_SAVE_NOT_ALLOWED_IMG_EXT."<br/>";
		$biConfig->ChmodRecursive($biConfig->absolutePath.$biConfig->imagesFolder,0775);
    	//echo $msg;
    	//return $msg;
    	return FALSE;
    }
    /**
     * resampling image to adjusted size
     * @file string - filename
     */
    function resampleImage( $file , $mode )
    {
    	//global $mosConfig_absolute_path;
    	global $biConfig;
    	
    	$biConfig->ChmodRecursive($biConfig->absolutePath.$biConfig->imagesFolder,0775);

		if( $mode == 'img' )
		{
			$width = $biConfig->imgWidth;
			$height = $biConfig->imgHeight;
	    	$filename = $file;
		} else
		{
			$width = $biConfig->imgTmbWidth;
			$height = $biConfig->imgTmbHeight;
	    	$filename = 'tmb_'.$file;
		} //if

    	//$fileExt = substr( $file, -3 );
    	$file = $biConfig->absolutePath.$biConfig->imagesFolder.$file;

		if($width == 0 || $height == 0) {
			//$biConfig->logSobiError("resampleImage(): Invalid size value (w:{$width}, h:{$height} scope:{$scope})");
			return false;
			exit();
		}
    	/*
    	 * getting attributes
    	 */
    	list($width_orig, $height_orig, $imgType) = getimagesize($file);

		/* if not image */
		if(!$width_orig || !$height_orig || !$imgType)
		{
			echo 'Cannot get info about uploaded image. Probably file is not an image - removing';
			//$biConfig->logSobiError("resampleImage(): Cannot get info about uploaded image. Probably file is not an image - removing");
			if(!unlink($file))
				//$biConfig->logSobiError("resampleImage(): Cannot delete false image");
				echo 'resampleImage(): Cannot delete false image';
		}

    	if($width_orig == 0 || $height_orig == 0)
    	{
			//$biConfig->logSobiError("resampleImage(): Invalid size value from list of original image (w_o:{$width_orig}, h_o:{$height_orig} scope:{$scope})");
			echo 'resampleImage(): Invalid size value from list of original imag';
			return false;
			exit();
		}
		/*
		 * build new filename
		 */

    	/*
    	 * case the image is NOT bigger as adjusted size
    	 */
    	if(($width_orig < $width) && ($height_orig < $height))
    		return $filename;

    	$ratio_orig = $width_orig/$height_orig;

		if ($width/$height > $ratio_orig)
		   $width = $height*$ratio_orig;
		else
		   $height = $width/$ratio_orig;

		if( (!function_exists('imagecreatetruecolor')) 	||
			(!function_exists('imagecreatefromgif')) 	||
			(!function_exists('imagecopyresampled'))	||
			(!function_exists('imagegif')) 				||
			(!function_exists('imagecreatefromgif')) 	||
			(!function_exists('imagecreatefromjpeg')) 	||
			(!function_exists('imagecreatefrompng'))
		) {
			//$biConfig->logSobiError("resampleImage(): Missing GD Libs");
		}

		switch($imgType) {
			case 1:
				if(!($image_p = imagecreatetruecolor($width, $height)))
					return false;
				if(!($image = imagecreatefromgif($file)))
					return false;
				if(!(imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig)))
					return false;
				if(!(imagegif($image_p, $biConfig->absolutePath.$biConfig->imagesFolder.$filename)))
					return false;
			break;
			case 2:
				if(!($image_p = imagecreatetruecolor($width, $height)))
					return false;
				if(!($image = imagecreatefromjpeg($file)))
					return false;
				if(!(imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig)))
					return false;
				if(!(imagejpeg($image_p, $biConfig->absolutePath.$biConfig->imagesFolder.$filename)))
					return false;
			break;
			case 3:
				if(!($image_p = imagecreatetruecolor($width, $height)))
					return false;
				if(!($image = imagecreatefrompng($file)))
					return false;
				if(!(imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig)))
					return false;
				if(!(imagepng($image_p, $biConfig->absolutePath.$biConfig->imagesFolder.$filename)))
					return false;
			break;
		}
		imagedestroy($image_p);
		imagedestroy($image);
		$biConfig->ChmodRecursive($biConfig->absolutePath.$biConfig->imagesFolder,0775);
		return $filename;
    }
    
    /**
     * 		save edited file
     */
    function saveTemplate ( $file_name, $mode )
	{
		global $biConfig;
		global $DBG;
		
		$subDir = '';
		switch( $mode )
		{
			case 1:
				$subDir = 'item/';
			break;
			case 2:
				$subDir = 'directory/';
			break;
			case 3:
				$subDir = 'app/';
			break;
			default:
				echo 'No subdir';
				return FALSE;
			break;
		}
		
		
		if( get_magic_quotes_gpc() )
		{
		$code_php = stripslashes($_POST['code_php']);
		$code_css = stripslashes($_POST['code_css']);
		}
		else
		{
			$code_php = $_POST['code_php'];
			$code_css = $_POST['code_css'];
		}
$DBG->out("templatepath:".$biConfig->templatePath.$subDir.'--'.$biConfig->absolutePath);
$full_path = $biConfig->absolutePath.'/'.$biConfig->templatePath.$subDir.$file_name;
echo $full_path.'.php';
if( ! is_writable($full_path.'.php') )
{
	HTML_BIndex::msgError( BI_NOT_WRITEABLE );
	return FALSE;
} //if
$DBG->out($full_path);
	$res1 = file_put_contents( $full_path.'.php', $code_php );
	$res2 = file_put_contents( $full_path.'.css', $code_css );
		
	return ( ( $res1 == FALSE ) || $res2 == FALSE ) ? FALSE : TRUE;//|| PEAR::isError( $res )) {
/*
		$err = basename($file_name).": ".$GLOBALS["error_msg"]["savefile"];
		if( PEAR::isError( $res ) ) {
			$err .= $res->getMessage();
		}
		show_error( $err );
	}
*/	
	} //function
	
}//class

class fields
{
	//var $id_field		= 0;
	//var $id_bindex		= 0;
	//var $language		= NULL;
	var $published		= NULL;
}

class fields_titles
{
	var $id_field		= 0;
	var $language		= NULL;
	var $value			= NULL;
}

class fields_text
{
	var $id_field		= 0;
	var $id_bindex		= 0;
	var $language		= NULL;
	var $value			= NULL;
}
/*
class biConfig extends mosDBTable
{
	var $AppName		= NULL;
	var $AppVersion	= NULL;//in DB
	
	var $absolutePath	= NULL;
	var $liveSite		= NULL;
	
	var $list_limit 	= 0;
	var $directory_items_in_row	= 0;
	
	var $showMenuNotLoggedIn	= 0;

	var $act_language	= NULL;
	var $ini_language	= NULL;
	
	var $imagesFolder	= NULL;
	var $allowableFilesExt = array ('gif','jpg','png');
	var $cmod 			= 0;
	var $dmod 			= 0;
	var $fmod 			= 0;
	var $maxFileSize 	= null;
	var $imgWidth 		= 0;
	var $imgHeight 	= 0;
	var $imgTmbWidth	= 0;
	var $imgTmbHeight	= 0;
	
	var $editorWidth	= NULL;
	var $editorHeight	= 0;
	
	var $templatePath	= NULL;
	var $template		= NULL;
	
	var $GMapKey					= NULL;
	var $GMapGBasePath				= NULL;
	var $GMapCustomBasePath		= NULL;
	var $GMapMainCenterPointLat	= 0;
	var $GMapMainCenterPointLng	= 0;
	var $GMapMainZoom				= 0;
	var $GMapMainWidth				= 0;
	var $GMapMainHeight			= 0;
	
	var $DEBUG = NULL;
	var $LOG = NULL;
	
 	function biConfig() {

		global $database;
		global $biConfig;
		$DB = NULL;
		$query = "SELECT * FROM #__bindex_config";
		$database->setQuery($query);
		$database->loadObject($DB);
				if ($database->getErrorNum())
			echo '<h1>'.$database->stderr().'</h1>';
//debugOut($DB);
		
		$this->AppVersion 	= $DB->app_version;
		$this->list_limit 	= $DB->list_limit;

		$this->directory_items_in_row	= $DB->directory_items_in_row;
		
		$this->showMenuNotLoggedIn	= $DB->show_menu_not_logged_in;

		$this->imagesFolder = $DB->images_folder;
		$this->maxFileSize	= $DB->max_file_size;
		$this->imgWidth		= $DB->img_width;
		$this->imgHeight	= $DB->img_height;
		$this->imgTmbWidth	= $DB->img_tmb_width;
		$this->imgTmbHeight	= $DB->img_tmb_height;
		
		$this->editorWidth	= $DB->editor_width;
		$this->editorHeight	= $DB->editor_height;
		
		$this->template		= $DB->template;
		
		$this->GMapKey		= $DB->gmap_key;
		$this->GMapGBasePath	= $DB->gmap_g_basepath;
		$this->GMapCustomBasePath	= $DB->gmap_custom_basepath;
		$this->GMapMainCenterPointLat	= $DB->gmap_main_centerpoint_lat;
		$this->GMapMainCenterPointLng	= $DB->gmap_main_centerpoint_lng;
		$this->GMapMainZoom				= $DB->gmap_main_zoom;
		$this->GMapMainWidth			= $DB->gmap_main_width;
		$this->GMapMainHeight			= $DB->gmap_main_height;
		
		$this->DEBUG		= $DB->debug;
		$this->LOG			= $DB->log;
		
	}
	
	function getConfigFromRequest ()
	{
		$this->list_limit 				= intval( mosGetParam( $_POST, 'list_limit', 10 ) );
		$this->directory_items_in_row	= intval( mosGetParam( $_POST, 'directory_items_in_row', 0 ) );

		$this->showMenuNotLoggedIn		= intval( mosGetParam( $_POST, 'show_menu_not_logged_in', 0 ) );

		$images_folder 		= mosGetParam( $_POST, 'images_folder', '');
		$max_file_size 		= intval( mosGetParam( $_POST, 'max_file_size', 0) );
		$img_width			= intval( mosGetParam( $_POST, 'img_width', 0) );
		$img_height			= intval( mosGetParam( $_POST, 'img_height', 0) );
		$img_tmb_width		= intval( mosGetParam( $_POST, 'img_tmb_width', 0) );
		$img_tmb_height		= intval( mosGetParam( $_POST, 'img_tmb_height', 0) );

		$editor_width 		= intval( mosGetParam( $_POST, 'editor_width', '') );
		$editor_height 		= intval( mosGetParam( $_POST, 'editor_height', '') );
		
		$temlate			= mosGetParam( $_POST, 'template', '' );

		$this->GMapKey					= mosGetParam( $_POST, 'gmap_key', 0 );
		$this->GMapGBasePath			= mosGetParam( $_POST, 'gmap_g_basepath', '' );
		$this->GMapCustomBasePath		= mosGetParam( $_POST, 'gmap_custom_basepath', '' );
		$this->GMapMainCenterPointLat	= floatval( mosGetParam( $_POST, 'gmap_main_center_lat', '' ) );
		$this->GMapMainCenterPointLng	= floatval( mosGetParam( $_POST, 'gmap_main_center_lng', '' ) );
		$this->GMapMainZoom				= mosGetParam( $_POST, 'gmap_main_zoom', '' );
		$this->GMapMainWidth			= mosGetParam( $_POST, 'gmap_main_width', '' );
		$this->GMapMainHeight			= mosGetParam( $_POST, 'gmap_main_height', '' );
		
		
		$log 				= intval( mosGetParam( $_POST, 'LOG', 2) );
		$debug				= intval( mosGetParam( $_POST, 'DEBUG', 2) );

		if( $images_folder != '' )	$this->imagesFolder = $images_folder; 
		if( $max_file_size > 0 ) 	$this->maxFileSize = $max_file_size;
		if( $img_width > 0) 		$this->imgWidth = $img_width;
		if( $img_height > 0 ) 		$this->imgHeight = $img_height;
		if( $img_tmb_width > 0) 	$this->imgTmbWidth = $img_tmb_width;
		if( $img_tmb_height > 0 ) 	$this->imgTmbHeight = $img_tmb_height;
		
		if( $editor_width != '' ) 	$this->editorWidth = $editor_width; 
		if( $editor_height != '' )	$this->editorHeight = $editor_height; 

		if( $temlate != '' )		$this->template = $temlate; 

		if( $log < 2 )				$this->LOG = $log; 
		if( $debug < 2 )			$this->DEBUG = $debug; 
	} //function
	
	/**
	 * @return bol - true if stored ok
	 */
/*
	function biConfigStore()
	{
		global $database;
global $DBG;		
		$query = "UPDATE `#__bindex_config`"
				. "\n SET" .
					"\n `list_limit` = '".$this->list_limit."', " .
					"\n `directory_items_in_row` = '".$this->directory_items_in_row."', " .
					"\n `show_menu_not_logged_in` = '".$this->showMenuNotLoggedIn."', " .
					"\n `images_folder` = '".$this->imagesFolder."', " .
					"\n `max_file_size` = '".$this->maxFileSize."', " .
					"\n `img_width` = '".$this->imgWidth."', " .
					"\n `img_height` = '".$this->imgHeight."', " .
					"\n `img_tmb_width` = '".$this->imgTmbWidth."', " .
					"\n `img_tmb_height` = '".$this->imgTmbHeight."', " .
					"\n `editor_width` = '".$this->editorWidth."', " .
					"\n `editor_height` = '".$this->editorHeight."', " .
					"\n `gmap_key` = '".$this->GMapKey."', " .
					"\n `gmap_g_basepath` = '".$this->GMapGBasePath."', " .
					"\n `gmap_custom_basepath` = '".$this->GMapCustomBasePath."', " .
					"\n `gmap_main_centerpoint_lat` = '".$this->GMapMainCenterPointLat."', " .
					"\n `gmap_main_centerpoint_lng` = '".$this->GMapMainCenterPointLng."', " .
					"\n `gmap_main_zoom` = '".$this->GMapMainZoom."', " .
					"\n `gmap_main_width` = '".$this->GMapMainWidth."', " .
					"\n `gmap_main_height` = '".$this->GMapMainHeight."', " .
					"\n `template` = '".$this->template."', " .
					"\n `debug` = '".$this->DEBUG."', " .
					"\n `log` = '".$this->LOG."'";
		$database->setQuery($query);
		$database->query();
$DBG->query($query);
		
		return( $database->getErrorNum() ) ? FALSE : TRUE;
						
	} //function
	
	/**
	 * Returns ONE item id of
	 *       
	 *          option=com_bindex
	 */
/*
	function getMyItemID()
	{
		global $database;
global $DBG;
		
		$ret = NULL;
		$ms = NULL;
		$query = "SELECT `id`, `link`" .
				"\n FROM #__menu";
		$database->setQuery($query);
		$ms = $database->loadObjectList();
		foreach( $ms as $me )
		{
			$p = explode( "?", $me->link );
		//	$l = $p[1];
			$ops = explode( "&",  $p[1] );
			foreach( $ops as $ot )
			{
				$ox = explode( "=", $ot );
				if( (isset($ox[0]) && $ox[0]=='option')
					&& (isset($ox[1]) && $ox[1]=='com_bindex') )
				{
					$ret = $me->id;
				}//if
			}//foreach
		} //foreach
		
		return $ret;
	} //function
	
	function getVarText() {
		$txt = '';
		foreach ($this->_alias as $k=>$v) {
			$txt .= "\$$v = '".addslashes( $this->$k )."';\n";
		}
		return $txt;
	}

	function bindGlobals()
	{
		foreach ($this->_alias as $k=>$v) {
			if(isset($GLOBALS[$v]))
			$this->$k = $GLOBALS[$v];
			else
			$this->$k = "";
		}
	}	
	
		
		/**
	 * @param string $path
	 * @param int $fmode
	 * @param int $dmode
	 */
/*
	function chmodRecursive ( $path, $fmode = null, $dmode = null, $force = false )
	{
		if( !$this->cmod ) {
			return false;
		}
		if( !$force ) {
			$fmode = $this->fmod;
			$dmode = $this->dmod;
		}
		$fmode = $fmode < 600 ? decoct( $fmode ) : $fmode;
		$dmode = $dmode < 600 ? decoct( $dmode ) : $dmode;
		if( !strstr( strtoupper( PHP_OS ), "WIN") && function_exists( "exec") ) {
			$path = escapeshellarg( $path );
			if( $fmode ) {
				$fmode = (int) $fmode;
				@exec( "find {$path} -type f -exec chmod {$fmode} {} \;" );
			}
			if( $dmode ) {
				$dmode = (int) $dmode;
				@exec( "find {$path} -type d -exec chmod {$dmode} {} \;" );
			}
		}
		else {
			mosChmodRecursive( $path, $fmode, $dmode );
		}
	}
	
	function loadJS_Tooltips()
	{
		global $mainframe;
		global $biConfig;
	
		/***********************************************
		* Rich HTML Balloon Tooltip- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
		* This notice MUST stay intact for legal use
		* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
		***********************************************/
/*
		$mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="components/com_bindex/includes/js/tooltips/balloontip.css" />');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$biConfig->liveSite.'/components/com_bindex/includes/js/tooltips/balloontip.js"></script>' );
	} //function
	
	function bi_Load_JS_Lightbox ()
	{
		global $mainframe;
		global $biConfig;
		
		$basepath = $biConfig->liveSite.'/components/com_bindex/includes/js/lightbox/';
		#load JS
		
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/prototype.js"></script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/scriptaculous.js?load=effects"></script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/lightbox.js"></script>');

		$mainframe->addCustomHeadTag('<link rel="stylesheet" href="components/com_bindex/includes/js/lightbox/css/lightbox.css" type="text/css" media="screen" />');
	} //function

}//class
*/
class biItem
{
	var $B		= NULL;
	var $B_ref	= NULL;
	
	/**
	 * @param object $B as bindex
	 * @param object $B_ref as bindex - object for lang reference
	 */
	function biItem ( $B, $B_ref )
	{
		global $database;
global $DBG;
		$this->B 		= new bindex($database);
		$this->B_ref	= new bindex($database);
		$this->B = $B;
		$this->B_ref = $B_ref;
		#get commons
		$ret = NULL;
		$query = "SELECT * FROM #__bindex_items" .
				"\n WHERE `id` = '".$B_ref->id_item."'";
		$database->setQuery($query);
		$database->loadObject($ret);
$DBG->query($query);
		$this->B_ref->id_stadt = $ret->id_stadt;
		$this->B_ref->gmap_lat	= $ret->gmap_lat;
		$this->B_ref->gmap_lng	= $ret->gmap_lng;
	} //function
	
	function gmapLat()
	{
		return $this->B_ref->gmap_lat;
	}
	/**
	 * @param bol $return - false echoes
	 * @param str $link - the link <a href="..."
	 */
	function name( $return = FALSE, $link = FALSE )
	{  $val = ( $this->B->name ) ? $this->B->name : $this->B_ref->name;
		if( $link ) $val = "<a href='".$link."'>".$val."</a>";
		if( $return ) return $val;
		echo $val;
	} //function
	function street( $return = FALSE)
	{ 
		$val = ( $this->B->strasse ) ? $this->B->strasse : $this->B_ref->strasse;
		if( $return ) return $val;
		echo $val;
	} //function
	function street_number( $return = FALSE)
	{ 
		$val = ( $this->B->hausnummer ) ? $this->B->hausnummer : $this->B_ref->hausnummer;
		
		if( $return ) return $val;
		echo $val;
	} //function
	function telefone( $return = FALSE)
	{ $val = ( $this->B->telefon ) ? $this->B->telefon : $this->B_ref->telefon;
		if( $return ) return $val;
		echo $val;
	} //function
	function fax( $return = FALSE)
	{ $val = ( $this->B->fax ) ? $this->B->fax : $this->B_ref->fax;
		if( $return ) return $val;
		echo $val;
	} //function
	function description ( $return = FALSE)
	{ $val = ( $this->B->beschreibung ) ? $this->B->beschreibung : $this->B_ref->beschreibung;
		if( $return ) return str_replace("\"", "'", $val);
		echo $val;
	} //function
	function cloakedEmail()
	{ 
		$mail = ( $this->B->email ) ? $this->B->email : $this->B_ref->email;
		$test			= explode( '@', $mail );
		if(isset($test[0]) && isset($test[1]) ) 
		{
		$mail 			= mosHTML::encoding_converter( $mail );
		 echo mosHTML::emailCloaking( $mail );
		} //if
	} //function
	function city ( $return = FALSE)
	{
		global $mosConfig_lang;
		$val = getValueStadtOrDefault($this->B_ref->id_stadt, $mosConfig_lang);
		if( $return ) return $val;
		echo $val;
	} //function
	
	function image( $return = FALSE, $thumbnail = FALSE, $draw_filler = TRUE, $link = FALSE)
	{
		global $biConfig;
		
		$tmb = ( $thumbnail ) ? 'tmb_' : '';
		$base_path = $biConfig->liveSite.$biConfig->imagesFolder;
		$ret = NULL;
		$val = '';
		if( $this->B_ref->bild == '' )
		{ if( $draw_filler ) $ret =  $base_path.'no_image.png';
		} else
		{
			if( file_exists( $biConfig->absolutePath.$biConfig->imagesFolder.$tmb.$this->B_ref->bild ) )
			{ $ret = $base_path.$tmb.$this->B_ref->bild;
			} else
			{ if( $draw_filler ) $ret = $base_path.'no_image.png';
			} //if
		} //if
		
		if( $ret ) $val = '<img src="'.$ret.'" alt="img" border="0" />';
		$val = ($return) ? str_replace("\"", "'", $val) : $val;
		if( $link) $val = '<a href="'.$link.'">'.$val.'</a>';
		if( $return ) return $val;

		echo $val;

	} //function
	
	function drawIcon ()
	{
		global $mosConfig_lang;
		global $biConfig;
		
		$GMap = new gmap;
#		print_a($this->B_ref);
		
#			if( $id_bereich > 0 )
#	{
#		$bereich = new bereich( $id_bereich, $mosConfig_lang );
#		echo '<div class="gmap_header">'.$GMap->_drawGIconBereich($id_bereich, FALSE).'&nbsp;&nbsp;'.$bereich->name.'</div>';
#	} elseif( $id_stadt > 0)
#	{
		$o_id_bereich = getBereichFromIDstadt( $this->B_ref->id_stadt );
		$id_bereich = $o_id_bereich->id;
		$bereich = new bereich( $id_bereich, $mosConfig_lang );
		$GMap->_drawGIconBereich($id_bereich, FALSE);
#	} //if

		
		$GMap->_drawGIconBereich( $bereich->id );
	} //function
	
	function drawGlobe ( $link )
	{
		global $biConfig;
		
		if( $this->B_ref->gmap_lat > 0 )
		{
			$rel = '';
			if( $biConfig->GMapShowPopup )
			{
				$link = str_replace('index.php', 'index2.php', $link);
				$link .= '&amp;popup=1';
				$rel = ' rel="lightbox"';
			} //if
			
			$href = 'href="'.$link.'"';
			?>
			<a <?php echo $href . $rel; ?>  title="">
				<img src="components/com_bindex/images/globe2.png" border="0" alt="<?php echo BI_ITEM_HAS_ENTRY; ?>" title="<?php echo BI_ITEM_HAS_ENTRY; ?>" />
			</a>
			<?php	
		} //if
	} //function
	
	
	function drawBindexTTinfo ( $link_view )
	{
		global $biConfig;
		
		if( ! $this->B_ref->beschreibung ) return;
		
#		$title = ( $BIndex->name ) ? $BIndex->name : $BIndex_ref->name;
		$title = $this->name(true);
		$tooltip = '';
		
		$id =( $this->B_ref->id_item ); 
		//$tooltip .= "($id)&lt;br /&gt;";
		$tooltip .= $this->description(TRUE);
		?>
		<a href="<?php echo $link_view; ?>" rel="balloon<?php echo $id; ?>">
			<img src="components/com_bindex/images/info.png" alt="info" border="0" />
		</a>
		
		<div id="balloon<?php echo $id; ?>" class="balloonstyle">
			<img src="components/com_bindex/images/info.png" alt="" style="float: right; margin-left: 5px;" />
			<?php echo $tooltip; ?>
		</div>

		<?php
	} //function
	
	function drawEdit ( $link )
	{
		if( canEdit() )
		{
			?>
			<a href="<?php echo $link; ?>">
				<img src="components/com_bindex/images/edit.png" border="0" alt="<?php echo BI_EDIT; ?>" title="<?php echo BI_EDIT; ?>" />
			</a>
			<?php	
		}//if
		
	} //function

	function drawKill ( $link )
	{
		if( canEdit() )
		{
			?>
			<a href="<?php echo $link; ?>">
				<img src="components/com_bindex/images/publish_x.png" border="0" alt="<?php echo BI_DELETE; ?>" title="<?php echo BI_DELETE; ?>" />
			</a>
			<?php	
		}//if
		
	} //function

	
	function mapLocation ( $map_width='100%', $map_height = '350px', $info_style = 'info', $zoom = 1, $in_popup = FALSE )
	{
		global $mainframe, $database, $mosConfig_live_site;
		global $biConfig;

		if( $this->B_ref->gmap_lat > 0 )
		{
		
			$GMap = new gmap;
	
			if( ! $GMap->checkForAPIkey() ) return;

			$GMap->addHeadTag();
			$GMap->echo_NO_JS_WARNING();
			
			$GMapBasePath = $biConfig->GMapGBasePath;//'http://maps.google.com/mapfiles/kml/';
	
			//$mainframe->addCustomHeadTag( "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=".$biConfig->GMapKey."\" type=\"text/javascript\"></script>");
			$basepath = $biConfig->liveSite.'/components/com_bindex/includes/js/';
	
			//$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'gmap.js"></script>');
	
			$Markers = '';
			$repl = '';

			$bereich = new bereich;
			$bereich = getBereichFromIDstadt( $this->B_ref->id_stadt );
			
			$icon_pal 	= $bereich->icon_pal;
			$icon_no 	= $bereich->icon_no;
			$icon_name	= $bereich->icon_name;

			$Markers .= 'var posn = new GLatLng('.$this->B_ref->gmap_lat.', '.$this->B_ref->gmap_lng.');'."\n";

			if ( $icon_pal < 2)
			{
				if( $icon_name != '' )
				{ ### custom marker
	    			$img = $mosConfig_live_site.'/'.$biConfig->GMapCustomBasePath.$icon_name;
			      $dims = getimagesize($img);
			      $Markers .= "var icon = new Array(\"$img\",$dims[0],$dims[1]);\n";

$Markers .= "

	var tmp=new GIcon();
	tmp.image=icon[0];
	tmp.iconSize=new GSize(icon[1],icon[2]);
	subt=icon[2]/100*11;
	subt=Math.ceil(subt);
	var yps=icon[2]-subt;
	tmp.iconAnchor=new GPoint(10,yps);
	tmp.infoWindowAnchor=new GPoint(30,yps-50);
	var marker=new GMarker(posn,tmp);
";

				} else
				{
					$path_icon		= $GMapBasePath.'pal2/icon5.png';
					$path_icon_s	= $GMapBasePath.'pal2/icon5s.png';
					$Markers .= "var icon = new GIcon(baseIcon, '".$path_icon."', null, '".$path_icon_s."');";
					$Markers .= "var marker = new GMarker(posn, icon);\n";
				}
			} else
			{
				$path_icon		= $GMapBasePath.'pal'.$bereich->icon_pal.'/icon'.$bereich->icon_no.'.png';
				$path_icon_s	= $GMapBasePath.'pal'.$bereich->icon_pal.'/icon'.$bereich->icon_no.'s.png';
				$Markers .= "var icon = new GIcon(baseIcon, '".$path_icon."', null, '".$path_icon_s."');\n";
				$Markers .= "var marker = new GMarker(posn, icon);";
			}// if

			switch( $info_style )
			{
				case 'blowup':
					$Markers .= "GEvent.addListener(marker,\"click\",function()
												{
													map.showMapBlowup(marker.getPoint());
												}
											);";
					
				break;
			
				default:

			$TabEinsContent = $GMap->_UserTab( $this, 1, $in_popup );
			$TabZweiContent = $GMap->_UserTab( $this, 2, $in_popup );

			$Markers .= "var infoTabs = [
						new GInfoWindowTab(\"".htmlspecialchars(BI_MAP_TAB_ONE)."\", \"".$TabEinsContent."\"),
						new GInfoWindowTab(\"".BI_MAP_TAB_TWO."\", \"".$TabZweiContent."\")
						];
						GEvent.addListener(marker, 'click', function() {
						marker.openInfoWindowTabsHtml(infoTabs);
						});";

				
				break;
			} //switch

			$Markers .= "map.addOverlay(marker);\n";
//           echo "var image = new Array(\"$img\",$dims[0],$dims[1]);\n";
//            echo "var point = new GLatLng(\"$lat\",\"$lng\");\n";
//            echo "var marker = createMapMarker(point,image);\n";
//            echo "map.addOverlay(marker);\n";
//            echo "\n";


		$repl = '';
		// The Map "Window"
		$repl .= '<div id="gmap" style="width: '.$map_width.'; height: '.$map_height.';"></div>';
		// The Infobox
		$repl .= '<div id="gmap_infobox" align="left">Brought to you by:<br /><a href="http://www.nik-it.de">NiK-IT.de</a></div>';

		// me make the map ...
		$repl .= $GMap->FNinitMap;

	//set the center
		$repl .= "map.setCenter(new GLatLng( ".$this->B_ref->gmap_lat.", ".$this->B_ref->gmap_lng." ), 8);";
		
		$repl .= $GMap->InfoBox;
		
		$repl .= $Markers;	
		$repl .= "}
			}
		";

		$repl .= $GMap->FNslowDownIE;
		
		$repl .= $GMap->MAP_Close;

		echo $repl;// SpitItOut ;)

		}//if (lat >0)
	} //function
	
	    function mapMarker($lat, $lng, $img = "143.png")
    {
        if ($lat and $lng) {
            $dims = getimagesize($img);
            echo "var image = new Array(\"$img\",$dims[0],$dims[1]);\n";
            echo "var point = new GLatLng(\"$lat\",\"$lng\");\n";
            echo "var marker = createMapMarker(point,image);\n";
            echo "map.addOverlay(marker);\n";
            echo "\n";
            return true;
        } else {
            return false;
        }
    }
	
	
	
	function xmapLocation ( $map_width='100%', $map_height = '300px' )
	{
		global $mainframe, $database;
		global $biConfig;
		
#		$GMap = new gmap;
		
#		if( ! $GMap->checkForAPIkey() ) return;

		if( !$biConfig->GMapKey | $biConfig->GMapKey == '0' )
		{
			echo '<span style="color: red;">'.BI_NO_API_KEY.'</span>';
			return;
		}
	
		$GMapBasePath = $biConfig->GMapGBasePath;//'http://maps.google.com/mapfiles/kml/';

		$mainframe->addCustomHeadTag( "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=".$biConfig->GMapKey."\" type=\"text/javascript\"></script>");


#	    $biConfig->centerPointLat =  '0.0';
#	    $biConfig->centerPointLong = '0.0';
#	    $biConfig->MapsZoom = '1';
#
#	#	$MapEditString = '';
#		$link_item = '';

		$Markers = '';
		$MarkerString = '';
		$repl = '';



				if( $this->B_ref->gmap_lat > 0 )
				{
					$bereich = new bereich;
					$bereich = getBereichFromIDstadt( $this->B_ref->id_stadt );
					
					$icon_pal 	= $bereich->icon_pal;
					$icon_no 	= $bereich->icon_no;
					if ( $icon_pal<1 | $icon_no<1) {
						$icon_pal = 2;
						$icon_no = 5;
					}
					$path_icon		= $GMapBasePath.'pal'.$bereich->icon_pal.'/icon'.$bereich->icon_no.'.png';
					$path_icon_s	= $GMapBasePath.'pal'.$bereich->icon_pal.'/icon'.$bereich->icon_no.'s.png';
					$Markers .= 'var posn = new GLatLng('.$this->B_ref->gmap_lat.', '.$this->B_ref->gmap_lng.');';
					$Markers .= "var icon = new GIcon(baseIcon, '".$path_icon."', null, '".$path_icon_s."');";
					$Markers .= "var marker = new GMarker(posn, icon);";
					$TabEinsContent = $this->name(TRUE);
					$TabZweiContent = '';

					$Markers .= "var infoTabs = [
						new GInfoWindowTab(\"".htmlspecialchars('Kategorie')."\", \"".$TabEinsContent."\"),
						new GInfoWindowTab(\"_TAB_ZWEI\", \"".$TabZweiContent."\")
						];";
					
					$Markers .="
					GEvent.addListener(marker, 'click', function() {
					marker.openInfoWindowTabsHtml(infoTabs);
					});
					map.addOverlay(marker);\n";
					}//if (lat >0)

$MarkerString .= $Markers;

		$repl = '';
		// The Map "Window"
		$repl .= '<div id="gmap" style="width: '.$map_width.'; height: '.$map_height.';"></div>';
		// The Infobox
		$repl .= '<div id="gmap_infobox" align="left">Brought to you by:<br /><a href="http://www.nik-it.de">NiK-IT.de</a></div>';
		// me make the map ...
		$repl .= "<script type='text/javascript'>//<![CDATA[\n";
		// global var linked to div
		$repl .="var tst=document.getElementById('gmap');
				 var tstint;
				 ";
		// Functions to watch if the map has changed
		$repl .= "function checkMap()
			{
				if (GBrowserIsCompatible())
				{
					if (tst)
						if (tst.offsetWidth != tst.getAttribute(\"oldValue\"))
						{
							tst.setAttribute(\"oldValue\",tst.offsetWidth);

							if (tst.getAttribute(\"refreshMap\")==0)
							if (tst.offsetWidth > 0) {
								clearInterval(tstint);
								getMap();
								tst.setAttribute(\"refreshMap\", 1);
							} 
						}
				}
			}";

		// Function for displaying the map and marker
		$repl .= "function getMap()
			{
				if (tst.offsetWidth > 0) {
				var map = new GMap2(document.getElementById('gmap'));
					";
		//The icon	
		$repl .= "
		var baseIcon = new GIcon();
          baseIcon.iconSize=new GSize(32,32);
          baseIcon.shadowSize=new GSize(56,32);
          baseIcon.iconAnchor=new GPoint(16,32);
          baseIcon.infoWindowAnchor=new GPoint(16,0);";
	   	
	//the controls
		$repl .= "map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GOverviewMapControl());
				map.addControl(new GScaleControl());";

	//set the center
		if( $this->B_ref->gmap_lat > 0 )
		{
			$repl .= "map.setCenter(new GLatLng( ".$this->B_ref->gmap_lat.", ".$this->B_ref->gmap_lng." ), 8);";
			
		} else
		{
			$repl .= "map.setCenter(new GLatLng( $biConfig->centerPointLat, $biConfig->centerPointLong ), $biConfig->MapsZoom);";
		} //if

	//InfoBox
	$InfoBox = "var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(460,20));
      pos.apply(document.getElementById('gmap_infobox'));
      map.getContainer().appendChild(document.getElementById('gmap_infobox'));";

	$repl .= $InfoBox;
	$repl .= $Markers;	
	$repl .= "}
		}
		//]]></script>
		";


////Here comes the mysterious Timeoutcode for FCKNG IE #*+-
		// Call the Maps through timeout to render in IE also
		// Set an event for watching the changing of the map so it can refresh itself
	
	$repl .= "<script type=\"text/javascript\">//<![CDATA[\n";
			
	$repl .="if (GBrowserIsCompatible()) {
				tst.setAttribute(\"oldValue\",0);
				tst.setAttribute(\"refreshMap\",0);
				tstint=setInterval(\"checkMap()\",500);
			}
		//]]></script>
		";

		echo $repl;// SpitItOut ;)

	} //function
	
} //class


class bereich {
	
	var	$name		= NULL;
	var	$icon_pal	= 0;
	var	$icon_no	= 0;
	var	$icon_name	= NULL;
	
	function bereich ( $id = NULL, $language_code = NULL )
	{
		global $database;
		global $biConfig;
		
		if( $id )
		{
			$ret = new bereich;
			$query = "SELECT * FROM #__bindex_bereiche" .
					"\n WHERE `id` = '".$id."'";
			$database->setQuery($query);
			$database->loadObject( $ret );
			
			$this->id			= $id;
			$this->icon_pal	= $ret->icon_pal;
			$this->icon_no		= $ret->icon_no;
			$this->icon_name	= $ret->icon_name;
			
			if( !$language_code )
			{
				$this->name = $this->getName( $id, $biConfig->ini_language);
			} else
			{
				$this->name = $this->getName( $id, $language_code );
			} //if

		return( $ret ) ? $ret: FALSE;
		} //if
	}//function
	
	
	function getFromID ( $id )
	{
		global $database;
		
		$ret = new bereich;
		$query = "SELECT * FROM #__bindex_bereiche" .
				"\n WHERE `id` = '".$id."'";
		$database->setQuery($query);
		$database->loadObject( $ret );
		
		$this->id			= $id;
		$this->icon_pal		= $ret->icon_pal;
		$this->icon_no		= $ret->icon_no;
		$this->icon_name	= $ret->icon_name;
		return( $ret ) ? $ret: FALSE;
		
	} //function
	
	function getName ( $id_bereich, $language_code )
	{
		global $database;
		$q = "SELECT `value`" .
			"\n FROM `#__bindex_bereiche_data`" .
			"\n WHERE `id_bereich` = '$id_bereich'" .
			"\n AND `language` = '$language_code'".
			"\n LIMIT 1";
		$database->setQuery($q);
		$v = $database->loadResult();
		return $v;
	} //function

	function getNameOrDefault ( $language_code )
	{
		global $biConfig;
		$string = $this->getName ( $this->id, $language_code );
		if( !$string ) $string = $this->getName ( $this->id, $biConfig->ini_language );
		
		return $string;
	} //function
	
	/**
	 * @param int $id - stadt
	 * @param str $language_code
	 * @return string - value of "Stadt"
	 */
	function getValueStadt ( $id, $language_code )
	{
		global $database;
//global $DBG;
		$query = "SELECT `value`" .
			"\n FROM `#__bindex_staedte_data`" .
			"\n WHERE `id_stadt` = '$id'" .
			"\n AND `language` = '$language_code'";
		$database->setQuery($query);
		$v = $database->loadResult();
//$DBG->query($query);
		return $v;
	} //function
	
	/**
	 * 
	 */
	function getValueStadtOrDefault ( $id, $language_code )
	{
		global $biConfig;
		$string = getValueStadt ( $id, $language_code );
		if( !$string ) $string = getValueStadt ( $id, $biConfig->ini_language );
		
		return $string;
	} //function
	
} //class

class logger
{
	var $active	= 0;
	var $dbTable	= NULL;
	
	function errDB ( $message = '' )
	{
		
	} //function
}
/* SQL DATA
 * 
 * 
 * -- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_bereiche`
-- 

DROP TABLE IF EXISTS `jos_bindex_bereiche`;
CREATE TABLE IF NOT EXISTS `jos_bindex_bereiche` (
  `id` int(11) NOT NULL auto_increment,
  `icon_pal` int(11) default NULL,
  `icon_no` int(11) default NULL,
  `published` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;

-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_bereiche_data`
-- 

DROP TABLE IF EXISTS `jos_bindex_bereiche_data`;
CREATE TABLE IF NOT EXISTS `jos_bindex_bereiche_data` (
  `id` int(11) NOT NULL auto_increment,
  `id_bereich` int(11) NOT NULL default '0',
  `language` varchar(20) NOT NULL default '',
  `value` varchar(150) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `id_bereich` (`id_bereich`)
) ENGINE=MyISAM;

-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_config`
-- 

DROP TABLE IF EXISTS `jos_bindex_config`;
CREATE TABLE IF NOT EXISTS `jos_bindex_config` (
  `id` int(11) NOT NULL auto_increment,
  `app_version` varchar(10) NOT NULL default '',
  `list_limit` int(11) NOT NULL default '0',
  `view_mode` varchar(10) NOT NULL default '',
  `buttons_show` varchar(10) default NULL,
  `directory_items_in_row` int(11) NOT NULL default '0',
  `show_menu_not_logged_in` tinyint(4) NOT NULL default '0',
  `images_folder` varchar(50) NOT NULL default '',
  `max_file_size` int(11) NOT NULL default '0',
  `img_width` int(11) NOT NULL default '0',
  `img_height` int(11) NOT NULL default '0',
  `img_tmb_width` int(11) NOT NULL default '0',
  `img_tmb_height` int(11) NOT NULL default '0',
  `editor_width` int(11) NOT NULL default '0',
  `editor_height` int(11) NOT NULL default '0',
  `template_item` varchar(50) NOT NULL default '',
  `template_directory` varchar(50) default NULL,
  `template_app` varchar(50) default NULL,
  `gmap_key` varchar(250) default NULL,
  `gmap_active` tinyint(4) NOT NULL default '0',
  `gmap_g_basepath` varchar(250) default NULL,
  `gmap_custom_basepath` varchar(250) default NULL,
  `gmap_main_centerpoint_lat` double default NULL,
  `gmap_main_centerpoint_lng` double default NULL,
  `gmap_main_zoom` int(11) default NULL,
  `gmap_main_width` varchar(7) default NULL,
  `gmap_main_height` varchar(7) default NULL,
  `gmap_show_popup` tinyint(4) NOT NULL default '0',
  `gmap_popup_width` varchar(7) default NULL,
  `gmap_popup_height` varchar(7) default NULL,
  `gmap_popup_zoom` int(11) default NULL,
  `debug` tinyint(4) default NULL,
  `log` tinyint(4) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;

-- 
-- Daten fuer Tabelle `jos_bindex_config`
-- 

INSERT INTO `jos_bindex_config` (`id`, `app_version`, `list_limit`, `view_mode`, `buttons_show`, `directory_items_in_row`, `show_menu_not_logged_in`, `images_folder`, `max_file_size`, `img_width`, `img_height`, `img_tmb_width`, `img_tmb_height`, `editor_width`, `editor_height`, `template_item`, `template_directory`, `template_app`, `gmap_key`, `gmap_active`, `gmap_g_basepath`, `gmap_custom_basepath`, `gmap_main_centerpoint_lat`, `gmap_main_centerpoint_lng`, `gmap_main_zoom`, `gmap_main_width`, `gmap_main_height`, `gmap_show_popup`, `gmap_popup_width`, `gmap_popup_height`, `gmap_popup_zoom`, `debug`, `log`) VALUES (1, '0.0', 9, 'directory', 'icons', 3, 0, '/images/com_bindex/clients/', 2000, 400, 300, 50, 50, 0, 0, 'template1', 'directory', 'light', '', 0, 'http://maps.google.com/mapfiles/kml/', 'bisher nix', 50.4854735458, 10.2392578125, 6, '100%', '500px', 1, '100%', '560px', 8, 0, 1);

-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_items`
-- 

DROP TABLE IF EXISTS `jos_bindex_items`;
CREATE TABLE IF NOT EXISTS `jos_bindex_items` (
  `id` int(11) NOT NULL auto_increment,
  `id_stadt` int(11) NOT NULL default '0',
  `gmap_lat` double NOT NULL default '0',
  `gmap_lng` double NOT NULL default '0',
  `published` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;


-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_items_data`
-- 

DROP TABLE IF EXISTS `jos_bindex_items_data`;
CREATE TABLE IF NOT EXISTS `jos_bindex_items_data` (
  `id` int(11) NOT NULL auto_increment,
  `id_item` int(11) NOT NULL default '0',
  `language` varchar(20) NOT NULL default '',
  `name` varchar(40) NOT NULL default '',
  `strasse` varchar(100) NOT NULL default '',
  `hausnummer` varchar(10) NOT NULL default '',
  `telefon` varchar(80) NOT NULL default '',
  `fax` varchar(80) NOT NULL default '',
  `email` varchar(40) NOT NULL default '',
  `bild` varchar(250) NOT NULL default '',
  `beschreibung` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;


-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_staedte`
-- 

DROP TABLE IF EXISTS `jos_bindex_staedte`;
CREATE TABLE IF NOT EXISTS `jos_bindex_staedte` (
  `id` int(11) NOT NULL auto_increment,
  `id_bereich` int(11) NOT NULL default '0',
  `published` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;


-- --------------------------------------------------------

-- 
-- Tabellenstruktur fuer Tabelle `jos_bindex_staedte_data`
-- 

DROP TABLE IF EXISTS `jos_bindex_staedte_data`;
CREATE TABLE IF NOT EXISTS `jos_bindex_staedte_data` (
  `id` int(11) NOT NULL auto_increment,
  `id_stadt` int(11) NOT NULL default '0',
  `language` varchar(20) NOT NULL default '',
  `value` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `id_stadt` (`id_stadt`)
) ENGINE=MyISAM;



*/
?>